package com.googlecode.ozonbooksfinder.cairngormfinder.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.googlecode.ozonbooksfinder.cairngormfinder.model.CairngormFinderModelLocator;
	
	import flash.net.SharedObject;
	
	import mx.collections.ArrayCollection;
	
	public class GetFavoritesCommand implements ICommand
	{
		private var model:CairngormFinderModelLocator = CairngormFinderModelLocator.getInstance();
		
		private var favoritesSO:SharedObject = SharedObject.getLocal("favorites");
		
		public function execute(event:CairngormEvent):void
	   	{
	   		var favorites:ArrayCollection = new ArrayCollection ();
			
			if (favoritesSO.data.favorites != null)
			{
				favorites.source = favoritesSO.data.favorites as Array;
			}
			
			model.favoritesDataProvider = favorites;
	   	}
	}
}